import React, { Component } from 'react'
import Header from '../../components/Header/Header'
import { Button, Form, Input,Toast } from 'antd-mobile'
import '../Login/Login.less'
import Logo from '../../assets/img/logo.png'
import {reqregister} from '../../request/api'
import { connect } from 'react-redux'
import { getUser } from '../../store/mouble/register'
import { bindActionCreators } from 'redux'
import { actions as regActions} from '../../store/mouble/register'
 class Register extends Component {
  
  render() {
  console.log(this.props);
  let {user,regFn:{changeuser,doRegister},history:{push}}=this.props
    return (
      <div className='login'>
      <Header title={'手机注册'} back></Header>
      <div className='form'>
      <img src={Logo} alt="" />
      <Form layout='horizontal'>
        <div>{JSON.stringify(user)}</div>
        <Form.Item label='用户名' >
          <Input placeholder='请输入用户名' clearable onChange={(e)=>{changeuser('phone',e)}}/>
        </Form.Item>
        <Form.Item label='昵称' >
          <Input placeholder='请输入昵称' clearable onChange={(e)=>{changeuser('nickname',e)}} />
        </Form.Item>
        <Form.Item label='密码' >
          <Input placeholder='请输入密码' clearable type='password' onChange={(e)=>{changeuser('password',e)}} />
        </Form.Item>
      </Form>
      <div>
        <Button block color='success' size='middle'  onClick={()=>{doRegister(push)}}>
          注册
        </Button>
      </div>
      </div>
    </div>
    )
  }
}
const mapStateToProps=(state)=>{
  return{
    user:getUser(state)
  }
}
const mapDispatchToProps=(dispatch)=>{
  return{
    regFn:bindActionCreators(regActions,dispatch)
  }
}
export default connect(mapStateToProps,mapDispatchToProps)(Register)
